#include "RadioButton.h"


namespace Zaf {
namespace Mwl {


RadioButton::RadioButton() {
	CommonConstructor();
}


RadioButton::RadioButton(WORD id) : ButtonWindow(id) {
	CommonConstructor();
}


void RadioButton::CommonConstructor() {
	SetButtonType(BS_AUTORADIOBUTTON);
}



RadioButton::~RadioButton() {

}


bool RadioButton::IsPushLike() const {
	return HasStyle(BS_PUSHLIKE);
}


void RadioButton::IsPushLike(bool value) {
	ChangeStyle(BS_PUSHLIKE, value);
	InvalidateRect(GetHandle(), nullptr, true);
}


bool RadioButton::IsAutoSelect() const {
	return GetButtonType() == BS_AUTORADIOBUTTON;
}


void RadioButton::IsAutoSelect(bool value) {
	SetButtonType(value == true ? BS_AUTORADIOBUTTON : BS_RADIOBUTTON);
}

bool RadioButton::IsSelected() const {
	return SendMessage(GetHandle(), BM_GETCHECK, 0, 0) == BST_CHECKED;
}

void RadioButton::IsSelected(bool value) {

	SendMessage(
		GetHandle(), 
		BM_SETCHECK, 
		value == true ? BST_CHECKED : BST_UNCHECKED, 0
	);
}


}
}